package borge.web.teamspirit.client.servercomm;

import java.io.Serializable;
import java.util.List;

import borge.web.teamspirit.client.data.Person;
import borge.web.teamspirit.client.interfaces.PersistentData;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

/**
 * The client side stub for the RPC service.
 */
@RemoteServiceRelativePath("data")
public interface DataService extends RemoteService {

    // Save methods
	//TODO: We must be able to generalize these somehow...
	/*
	DBQueryResult<TeamPlayer> savePlayer(TeamPlayer aPlayer);
	DBQueryResult<Serie> saveSerie(Serie aSerie);
	DBQueryResult<Match> saveMatch(Match aMatch);
	DBQueryResult<News> saveNews(News aNews);
	DBQueryResult<Event> saveEvent(Event aEvent);*/
	
	DBQueryResults isFieldUnique(DBQuery aQuery);
	
	/*
	DBQueryResult<TeamPlayer> deletePlayer(TeamPlayer aPlayer);
	DBQueryResult<Serie> deleteSerie(Serie aSerie);
	DBQueryResult<Match> deleteMatch(Match aMatch);
	DBQueryResult<News> deleteNews(News aNews);
	DBQueryResult<Event> deleteEvent(Event aEvent);*/
	
	<T extends Serializable> T getSessionValue(String aKey);
	
	DBQueryResults loginUser(String aUserName, String aPassword);
	DBQueryResults destroyUserSession(String aId);
	DBQueryResults isSessionValid(String aId);

	void testCreateEntities();
	void testPrintEntities();
	
	
	
	//DBQueryResult<TeamPlayer> getPlayerList(DBQuery aQuery);
	
	DBQueryResults genericQuery(DBQuery aQuery);
	
	DBQueryResults getAllSerieData(DBQuery aQuery);
	DBQueryResults getSerieStats(DBQuery aQuery);
	DBQueryResults getAllSeriesStats(List<DBQuery> aQueries);
	// Generic methods would be best, but GWT has poor support for it..
	<T extends PersistentData> DBQueryResults saveObject(T aObject);
	DBQueryResults deleteObject(DBQuery aQuery);
	DBQueryResults getObjectList(DBQuery aQuery);
	DBQueryResults getObjectChildren(List<DBQuery> aQueries);
}
